﻿<Window x:Class="WpfVkontacteClient.AdditionalWindow.SelectUserWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
		xmlns:conv="clr-namespace:WpfVkontacteClient.Converters"
        Title="Выбор пользователя" Height="320" Width="420"
		Loaded="Window_Loaded" WindowStyle="ToolWindow" WindowStartupLocation="CenterScreen"
		SnapsToDevicePixels="True" ResizeMode="NoResize" Icon="/WpfVkontacteClient;component/Images/User1.ico"
		FocusManager.FocusedElement="{Binding ElementName=cmbUsers}" >
	<Window.Resources>
		<Style TargetType="{x:Type TextBox}">
			<Setter Property="Margin" Value="2,0,2,0"/>
			<Setter Property="SnapsToDevicePixels" Value="True"/>
		</Style>
		<Style TargetType="{x:Type TextBlock}">
			<Setter Property="Margin" Value="3,0,0,0"/>
			<Setter Property="FontSize" Value="11"/>
			<Setter Property="FontStyle" Value="Italic"/>
			<Setter Property="SnapsToDevicePixels" Value="True"/>
		</Style>
		<conv:ReverseBoolToBool x:Key="Reverse"/>
	</Window.Resources>
	<Grid Background="{StaticResource GlassWindowBackground}"
		  DataContext="{Binding RelativeSource={RelativeSource  AncestorType=Window, Mode=FindAncestor}, 
								Path=SelectedUser}">
		<Grid.ColumnDefinitions>
			<ColumnDefinition/>
			<ColumnDefinition/>
		</Grid.ColumnDefinitions>
		<Grid.RowDefinitions>
			<RowDefinition Height="30"/>
			<RowDefinition/>
			<RowDefinition/>
		</Grid.RowDefinitions>
		<ComboBox x:Name="cmbUsers" ItemsSource="{Binding}"
				  Height="23" SelectionChanged="cmbUsers_SelectionChanged">
			<ComboBox.ItemTemplate>
				<DataTemplate>
					<TextBlock Text="{Binding UserName}"/>
				</DataTemplate>
			</ComboBox.ItemTemplate>
		</ComboBox>
		<StackPanel Grid.Column="1" Orientation="Horizontal">
			<Button x:Name="btnLoadUser" Content="Выбрать"
				Click="btnLoadUser_Click" Style="{DynamicResource MyButtonGlowStyle}"
				MinWidth="65"/>
			<Button x:Name="btnDeleteUser" Content="Удалить"
				Click="btnDeleteUser_Click" Style="{DynamicResource MyButtonGlowStyle}"
				MinWidth="65"/>
			<Button x:Name="btnRefresh" Content="Обновить"
				Click="btnRefresh_Click" Style="{DynamicResource MyButtonGlowStyle}"
				MinWidth="65"/>
		</StackPanel>
		<Expander Grid.RowSpan="2" Grid.Row="1" x:Name="expander1"
				  Grid.ColumnSpan="2" Header="Создание/Редактирование пользователя">
			<StackPanel Background="{StaticResource WindowFrameBrush}"
						DataContext="{Binding Path=SelectedUser, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}">
				<TextBlock Text="Имя пользователя:"/>
				<TextBox x:Name="txtUserName" Text="{Binding UserName, Mode=TwoWay}" IsReadOnly="{Binding ElementName=chkEdit, Path=IsChecked,Converter={StaticResource Reverse}}"/>
				<TextBlock Text="Пароль:" />
				<TextBox x:Name="txtUserPassword" Text="{Binding Password, Mode=TwoWay}"
						 IsReadOnly="{Binding ElementName=chkEdit, Path=IsChecked,Converter={StaticResource Reverse}}"/>
				<TextBlock Text="Application ID:"/>
				<TextBox x:Name="txtAppId" Text="{Binding AppId,Mode=TwoWay}"
						 IsReadOnly="{Binding ElementName=chkEdit, Path=IsChecked, Converter={StaticResource Reverse}}"/>
				<TextBlock Text="Access Key:"/>
				<TextBox x:Name="txtAccessKey" Text="{Binding AccessKey,Mode=TwoWay}"
						 IsReadOnly="{Binding ElementName=chkEdit, Path=IsChecked,Converter={StaticResource Reverse}}"/>
				<TextBlock Text="Email:"/>
				<TextBox x:Name="txtEmail"
						 IsReadOnly="{Binding ElementName=chkEdit, Path=IsChecked,Converter={StaticResource Reverse}}"/>
				<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
					<Button x:Name="btnCreate" Content="Создать"
						Click="btnCreate_Click" Style="{DynamicResource MyButtonGlowStyle}"
						Height="25" SnapsToDevicePixels="True" Width="60"/>
					<Button x:Name="btnEdit" Content="Редактировать"
						Click="btnEdit_Click" Style="{DynamicResource MyButtonGlowStyle}"
						Height="25" SnapsToDevicePixels="True" Width="90"
							IsEnabled="{Binding ElementName=chkEdit, Path=IsChecked}"/>
					<Button x:Name="btnDelete" Content="Удалить"
						Click="btnDelete_Click" Style="{DynamicResource MyButtonGlowStyle}"
						Height="25" SnapsToDevicePixels="True" Width="60"/>
					<Button Style="{DynamicResource MyButtonGlowStyle}"
						Content="Отмена" x:Name="btnCancel" IsCancel="True"
						Click="btnCancel_Click"
						Height="25" SnapsToDevicePixels="True" Width="60"/>
				</StackPanel>
				<CheckBox Content="Разрешить редактирование"
						  x:Name="chkEdit"/>
			</StackPanel>
		</Expander>
	</Grid>
</Window>
